/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 1000;
    vc.extends({
        data: {
            inspectionTaskDetailInfo: {
                inspectionPlanId: "",
                inspectionPlanName: "",
                originalPlanUserId: "",
                originalPlanUserName: "",
                planEndTime: "",
                planInsTime: "",
                planUserId: "",
                planUserName: "",
                signType: "",
                signTypeName: "",
                state: "",
                stateName: "",
                taskId: "",
                taskType: "",
                inspectionRouteId:'',
                total: 0,
                records: 1,
                moreCondition: false,
                inspectionName: '',
                pointObjTypes: [],
                _currentTab: 'pointTaskDetail',
            }
        },
        _initMethod: function () {
            $that.inspectionTaskDetailInfo.taskId = vc.getParam('taskId');

            //与字典表关联
            vc.getDict('inspection_point', "point_obj_type", function (_data) {
                $that.inspectionTaskDetailInfo.pointObjTypes = _data;
            });
            $that._listInspectionTaskDetails(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('inspectionTaskDetail', 'listInspectionTaskDetail', function (_param) {
                $that._listInspectionTaskDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listInspectionTaskDetails(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listInspectionTaskDetails: function (_page, _rows) {
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        communityId: vc.getCurrentCommunity().communityId,
                        taskId: $that.inspectionTaskDetailInfo.taskId
                    }
                };
                //发送get请求
                vc.http.apiGet('/inspectionTask.listInspectionTasks',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.inspectionTasks[0], $that.inspectionTaskDetailInfo);
                        $that.changeTab($that.inspectionTaskDetailInfo._currentTab);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },

            //查询
            _queryInspectionTaskDetailMethod: function () {
                $that._listInspectionTaskDetails(DEFAULT_PAGE, DEFAULT_ROWS);
            },

            changeTab: function (_tab) {
                $that.inspectionTaskDetailInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    taskId: $that.inspectionTaskDetailInfo.taskId,
                    inspectionPlanId: $that.inspectionTaskDetailInfo.inspectionPlanId,
                    inspectionRouteId: $that.inspectionTaskDetailInfo.inspectionRouteId,


                });
            },
            _moreCondition: function () {
                if ($that.inspectionTaskDetailInfo.moreCondition) {
                    $that.inspectionTaskDetailInfo.moreCondition = false;
                } else {
                    $that.inspectionTaskDetailInfo.moreCondition = true;
                }
            },
            _pointQrCode: function (_inspectionTaskDetail) {
                vc.emit('inspectionTaskDetailQrCode', 'openInspectionTaskDetailQrCodeModal', _inspectionTaskDetail);

            }
        }
    });
})(window.vc);